package com.example.myapplication.activity.advanced_activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.example.myapplication.R;

public class CheckBoxActivity extends AppCompatActivity {

    private CheckBox checkBox;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_check_box);
        checkBox = findViewById(R.id.ck_system);
        // 自定义勾选事件
        checkBox.setOnCheckedChangeListener((compoundButton, b) -> {
            if (b) {
                compoundButton.setText("被选中");
            } else {
                compoundButton.setText("没被选中");
            }
        });
    }
}